/**
 * Created by user on 2018/3/20.
 */
import { combineReducers } from 'redux'
import LoginState from './LoginState'
import MainScreenState from './MainScreenState'
import DmState from './DmState'
import LiveState from './LiveState'
import OnlineTeacherState from './OnlineTeacherState'
import QaState from './QaState'
import QaListState from './QaListState'
import QaFooterState from './QaFooterState'
import ToastState from './ToastState'
import NotStartState from './NotStartState'
import MaterialState from './MaterialState'
import ReplayState from './ReplayState'
import EndState from './EndState'
import DoLikeState from './DoLikeState'
import QuestionState from './QuestionState'
let combines = {
  MainScreenState,
  LoginState,
  DmState,
  LiveState,
  OnlineTeacherState,
  QaState,
  QaListState,
  QaFooterState,
  ToastState,
  NotStartState,
  MaterialState,
  ReplayState,
  EndState,
  DoLikeState,
  QuestionState
}
const rootReducer = combineReducers(combines)
let default_state = {}
Object.keys(combines).map(r => {
  default_state[r] = combines[r]._default_state
})
const appReducer = (state = default_state, action) => {
  if (action.type === 'RESET_GLOBAL_STATE') {
    state = default_state
  }
  return rootReducer(state, action)
}
export default appReducer
